﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UsersInRole.ascx.cs" Inherits="Web.Cms.Roles.UsersInRole" %>
<script language="javascript" type="text/javascript">
    function getUserInRole(idCheckbox) {
        var grid = document.getElementById("<%= grvUsersInRole.ClientID %>");
        //variable to contain the cell of the grid
        var cell;

        if (grid.rows.length > 0) {
            //loop starts from 1. rows[0] points to the header.
            for (i = 1; i < grid.rows.length; i++) {
                //get the reference of first column
                cell = grid.rows[i].cells[0];

                //loop according to the number of childNodes in the cell
                for (j = 0; j < cell.childNodes.length; j++) {
                    //if childNode type is CheckBox                 
                    if (cell.childNodes[j].type == "checkbox") {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                        cell.childNodes[j].checked = document.getElementById(idCheckbox).checked;
                    }
                }
            }
        }
    }
    function getUsers(idCheckbox) {
        var grid = document.getElementById("<%= grvUsers.ClientID %>");
        //variable to contain the cell of the grid
        var cell;

        if (grid.rows.length > 0) {
            //loop starts from 1. rows[0] points to the header.
            for (i = 1; i < grid.rows.length; i++) {
                //get the reference of first column
                cell = grid.rows[i].cells[0];

                //loop according to the number of childNodes in the cell
                for (j = 0; j < cell.childNodes.length; j++) {
                    //if childNode type is CheckBox                 
                    if (cell.childNodes[j].type == "checkbox") {
                        //assign the status of the Select All checkbox to the cell checkbox within the grid
                        cell.childNodes[j].checked = document.getElementById(idCheckbox).checked;
                    }
                }
            }
        }
    }
</script>

<table border="0" cellpadding="2" cellspacing="2" style="width: 100%">
    <tr>
        <td>
            <asp:Button ID="btnBack" runat="server" SkinID="AdminButtonBack" OnClick="btnBack_Click" /></td>
    </tr>
    <tr>
        <td class="InputBox" valign="top">
            <strong>Danh sách người dùng trong nhóm</strong>
            <asp:Label ID="lblRoleName" runat="server" Font-Bold="True" Font-Underline="True"></asp:Label></td>
        <td align="center" style="width: 86px" valign="top">
        </td>
        <td class="InputBox" valign="top">
            <strong>Danh sách người dùng trong hệ thống website</strong></td>
    </tr>
    <tr>
        <td char="InputBox" valign="top">
            <asp:GridView ID="grvUsersInRole" runat="server" AutoGenerateColumns="False" SkinID="AdminGrid"
                Width="100%" OnPageIndexChanging="grvUsersInRole_PageIndexChanging" PageSize="100"
                OnRowDataBound="grvUsersInRole_RowDataBound">
                <Columns>
                    <asp:TemplateField>
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderTemplate>
                            <asp:CheckBox runat="server" ID="checkedUserInRole" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkCheckUser" runat="server" />
                            <asp:Label ID="lblUserIDInRole" Visible="false" runat="server" Text='<%# Eval("UserID") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="Người d&#249;ng" DataField="Username" />
                    <asp:BoundField HeaderText="Email" DataField="Email" />
                </Columns>
            </asp:GridView>
        </td>
        <td align="center" style="width: 86px" valign="top">
            <br />
            <asp:Button ID="btnAdd" runat="server" SkinID="AdminButton" Text="<<" OnClick="btnAdd_Click" /><br />
            <br />
            <asp:Button ID="btnRemove" runat="server" SkinID="AdminButton" Text=">>" OnClick="btnRemove_Click" />&nbsp;<br />
            <br />
        </td>
        <td class="InputBox" valign="top">
            <asp:GridView ID="grvUsers" runat="server" AutoGenerateColumns="False" SkinID="AdminGrid"
                Width="100%" OnPageIndexChanging="grvUsers_PageIndexChanging" PageSize="100">
                <Columns>
                    <asp:TemplateField>
                        <HeaderStyle HorizontalAlign="Center" />
                        <ItemStyle HorizontalAlign="Center" />
                        <HeaderTemplate>
                            <asp:CheckBox runat="server" ID="checkUser" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="chkCheckUser" runat="server" />
                            <asp:Label ID="lblUserID" runat="server" Visible="false" Text='<%# Eval("UserID") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField HeaderText="Người d&#249;ng" DataField="Username" />
                    <asp:BoundField HeaderText="Email" DataField="Email" />
                </Columns>
            </asp:GridView>
        </td>
    </tr>
</table>
